<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateFilesTable extends Migration
{
    public function up()
    {
        Schema::create('files', function (Blueprint $table) {
            // 主键
            $table->id();
            
            // 文件名与存储
            $table->string('original_name')->comment('原始文件名（用户上传时的名称）');
            $table->string('stored_name')->unique()->comment('服务器存储的唯一文件名（避免重名）');
            $table->string('mime_type')->comment('MIME类型（如 image/jpeg、application/pdf）');
            $table->string('suffix')->nullable()->comment('文件后缀（如 jpg、pdf）');
            $table->string('path')->comment('存储相对路径（不含文件名，如 “uploads/2025/10/”）');
            
            // 时间戳与软删除
            $table->timestamps();
            $table->softDeletes()->comment('软删除时间');
        });
    }

    public function down()
    {
        Schema::dropIfExists('files');
    }
}